<?php
header("Content-type: text/html; charset=utf-8");
include_once('lib/tbs_class_php5.php');

//$TeamList[0] = array('type'=>'Progress');
//$TeamList[0]['matches'][] = array('title'=>'学习py和django，看共享资料中的视频；');
//$TeamList[0]['matches'][] = array('title'=>'检查会议PPT稿件和教程，整理演示流程；');
//$TeamList[1] = array('type'=>'Problem');
//$TeamList[1]['matches'][] = array('title'=>'补充adtree的演示资料；');
//$TeamList[1]['matches'][] = array('title'=>'制定自己的项目开发原则，目的减少最后BUG的数量；');
//$TeamList[2] = array('type'=>'Plan');
//$TeamList[2]['matches'][] = array('title'=>'深入研究Google Voice短信接口； ');
//$TeamList[2]['matches'][] = array('title'=>'掌握关于Linux服务器SecureCRT和Vim的命令；');
//$TeamList[2]['matches'][] = array('title'=>'sina素材内容生成器；');

$report=explode("\n",$_POST['report']);
$alltitle=array('Progress','Problem','Plan');
$ip=0;
$TeamList[$ip] = array('type'=>$alltitle[$ip]);
for($io=0;$io<count($report);$io++){
	if((isset($report[$io-1]) && $report[$io-1]=='')){
		$ip++;
		$TeamList[$ip] = array('type'=>$alltitle[$ip]);
	}
	if(isset($report[$io-1]) && $report[$io-1]==''){
		if($report[$io]=='')
			$TeamList[$ip]['matches'][] = array('title'=>'暂无');
	}
	
	if($report[$io]!=''){
		
		if(substr($report[$io],0,1)!='-')
			$TeamList[$ip]['matches'][] = array('title'=>$report[$io]);
		else{
			$nowin=count($TeamList[$ip]['matches'])-1;
			$newval=substr($report[$io],1,strlen($report[$io]));

			$TeamList[$ip]['matches'][$nowin][] = array('title'=>$newval);
			
		}
		
	}
}


$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('template/weekly.html') ;

// Automatic subblock
$TBS->MergeBlock('asb',$TeamList) ;

// Subblock with a dynamic query
$TBS->MergeBlock('mb','array','TeamList') ;
$TBS->MergeBlock('sb','array','TeamList[%p1%][matches]') ;
$TBS->MergeBlock('cb','array','TeamList[%p1%][matches][%p2%]');
//;

//echo Date( "Y-n-1" ) ;  //得到2006-3-1 
//echo strtotime( "2006-3-1" ) ;  //得到1141142400 (timestamp觀念請看上一篇) 
//echo Date( "D", 1141142400 ) ;  //得到Wed
//echo Date( "D", 1);  //得到Wed
$weekarray=array("日","一","二","三","四","五","六");
$noww= date("w");

//echo "星期".$weekarray[date("w")];
$x = changeWk(my_date_add('d',date("Y-m-d"),-($noww-1)));
//echo '--';
$y = changeWk(my_date_add('d',date("Y-m-d"),(5-$noww)));

function my_date_add($opt,$time,$num){
		$year = date('Y',strtotime($time));
		$month = date('m',strtotime($time));
		$day = date('d',strtotime($time));
		$last_day = date('t',strtotime($time));
		if($opt=='y'){
			$year = $year + $num;
		}else if($opt=='d'){
			$day = $day + $num;
		}else if($opt=='m'){
			$month = $month + $num;
			if($day == $last_day){//如果是最后一天的话
				$day = date('t',strtotime("{$year}-{$month}-01"));
			}
		} else {
			return $time;
		}
		return date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
	}

function changeWk($years){
	$years=explode('-',$years);
	$years=array_reverse($years);
	$years=$years[1].'/'.$years[0].'/'.$years[2];
	//$years=join('/',$years);
	return $years;
}

$TBS->Show()

?>